package com.melesta.engine;

import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

class AwardsHelper
{
  static AwardsHelper mInstance = new AwardsHelper();
  private final Map<String, String> mAchivements = new HashMap();
  private final Map<String, String> mLeaderboards = new HashMap();

  static AwardsHelper getHelper()
  {
    return mInstance;
  }

  private void loadAchievements(Node paramNode)
  {
    loadKeyValueMap(this.mAchivements, paramNode);
  }

  private static void loadKeyValueMap(Map<String, String> paramMap, Node paramNode)
  {
    paramMap.clear();
    NodeList localNodeList = paramNode.getChildNodes();
    int i = 0;
    if (i < localNodeList.getLength())
    {
      NamedNodeMap localNamedNodeMap = localNodeList.item(i).getAttributes();
      if (localNamedNodeMap == null);
      while (true)
      {
        i++;
        break;
        paramMap.put(localNamedNodeMap.getNamedItem("key").getNodeValue(), localNamedNodeMap.getNamedItem("value").getNodeValue());
      }
    }
  }

  private void loadLeaderboards(Node paramNode)
  {
    loadKeyValueMap(this.mLeaderboards, paramNode);
  }

  public String getAchievementId(String paramString)
  {
    return (String)this.mAchivements.get(paramString);
  }

  public Collection<String> getAchievementsIds()
  {
    return this.mAchivements.values();
  }

  public String getLeaderboardId(String paramString)
  {
    return (String)this.mLeaderboards.get(paramString);
  }

  void loadConfig(InputStream paramInputStream)
  {
    DocumentBuilderFactory localDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
    while (true)
    {
      int i;
      try
      {
        NodeList localNodeList = localDocumentBuilderFactory.newDocumentBuilder().parse(paramInputStream).getDocumentElement().getChildNodes();
        i = 0;
        if (i < localNodeList.getLength())
        {
          Node localNode = localNodeList.item(i);
          if (localNode.getNodeName().equals("achievements"))
            loadAchievements(localNode);
          else if (localNode.getNodeName().equals("leaderboards"))
            loadLeaderboards(localNode);
        }
      }
      catch (Exception localException)
      {
        Error.processException(null, localException);
      }
      return;
      i++;
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.melesta.engine.AwardsHelper
 * JD-Core Version:    0.6.2
 */